class Cpanel::UsersController < Cpanel::BaseController

  before_action :find_user

  def edit
  end

  def update
    unless params[:user][:password].blank?
      params[:user][:password_confirmation] = params[:user][:password]
    end
    if @user.update_attributes!(user_params)
      redirect_to cpanel_root_path, notice: 'password updated success'
    else
      flash[:notice] = 'password updated failed'
      render 'edit'
    end
  end

  private

  def find_user
    @user = User.find(params[:id])
  end

  def user_params
    params.require(:user).permit(:name, :password, :password_confirmation)
  end

end
